@{block #content}
<h3>{block #title}Přidání nového hráče{/block}</h3>

<div class="center_form">
@{if !isset($hodnoty)}
	@{block form}
		{snippet formSnippet}
		<div class="zapas_hrac_left">
			{widget hraciForm}
			
		</div>
		<div class="zapas_hrac_right">
			<form action="{link :Admin:Zapas:pridatHraceForm}" method="post" name="frm-hraciForm">
			{snippet pokus}
				{if isset($tymy)}
					<input type="hidden" value="{$vybrany_tym}" name="zapas" />
					<table class="form">
						<thead>
							<th></th><th>Název týmu</th><th>Akce</th>
						</thead>
						
						{foreach $tymy as $tym}
							<tr class="data_row {if $iterator->counter % 2 == 0}even{else}odd{/if}">
								<td><strong>{if $iterator->counter == 1}Tým A:{else}Tým B:{/if}</strong></td><td class="data">{$tym['nazev']}</td>
								<td>
									<a href="{link ukazHrace! 'id'=>$tym['id']}" class="ajax">
										<img src="/images/list-hraci.png" alt="Seznám hráčů" title="Seznám hráčů" />
									</a>
								</td>
							</tr>
						{/foreach}
					</table>
				{/if}
			
		
			{snippet hraci}

				{if isset($hraci)}
					<br />
					<table class="form">
						{if count($hraci) > 0}
							{foreach $hraci as $hrac}
								{if $iterator->first}
									<thead>
										<th>Jméno hráče</th><th>Pozice</th>
									</thead>
								{/if}
								<tr class="data_row {if $iterator->counter % 2 == 0}even{else}odd{/if}">
									<td class="data">{$hrac['jmeno']} {$hrac['prijmeni']}</td>
									<td class="data">
										<select name="{$hrac['tym_lide_id']}">
											<option value="">Zvolte pozici</option>
											{foreach $pozice as $k=>$v}
												<option value="{$k}">{$v}</option>
											{/foreach}
										</select>
									</td>
								</tr>

								</tr>
								{if $iterator->last}
								<tr>
									<td colspan="2"><input type="submit" value="Přidat" name="save" class="button"/>
									<input type="submit" value="Zpět" name="back" class="button" /></td>
								</tr>
								{/if}
							{/foreach}
						{else}
							
						{/if}
					</table>
			
				{/if}
			{/snippet}
			{/snippet}
			
			</form>
		</div>
		{/snippet}
	@{/block}
@{/if}
</div>
<script type="text/javascript">
	$(function(){
			$('select.ajax').live('change',function() {
					$.get({link change!},{"{!$control->getParamId('cislo')}": $('select.ajax').val()});

					return false;
			});
	});

	$(function(){
		$('a.ajax').live('click',function(){
			$.get(this.href);
			return false;
		});
	});
	
	
	
	
</script>

